//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.web.controller.member;

import com.aidong.dao.wills.CardTypeCodeDao;
import com.aidong.dao.wills.DicShopAreaCodeDao;
import com.aidong.dao.wills.MemberContractDao;
import com.aidong.model.wills.CardTypeCode;
import com.aidong.model.wills.MemberContract;
import com.aidong.web.controller.BaseController;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping({"contractShop"})
public class ContractShopController extends BaseController {
    @Resource
    MemberContractDao memberContractDao;
    @Resource
    CardTypeCodeDao cardTypeCodeDao;
    @Resource
    DicShopAreaCodeDao dicShopAreaCodeDao;

    public ContractShopController() {
    }

    @RequestMapping({"query"})
    public ModelAndView query() {
        return new ModelAndView("member/contractshop/query");
    }

    @RequestMapping({"_query"})
    public ModelAndView _query(@RequestParam("contractCode") String contractCode) {
        ModelAndView mv = new ModelAndView("member/contractshop/_query");
        MemberContract contract = this.memberContractDao.getByContractCode(contractCode);
        if(contract == null) {
            mv.addObject("errMsg", "没有这个合同");
            return mv;
        } else {
            List shopList1 = this.memberContractDao.getShopCodeByContractCode(contractCode);
            mv.addObject("shopList1", shopList1);
            if(!this.chkNull(contract.getManyShop())) {
                CardTypeCode cardType = (CardTypeCode)this.cardTypeCodeDao.getById(contract.getCardType());
                if(cardType != null && cardType.getManyShopQuantity().intValue() == 0) {
                    List shopList2 = this.dicShopAreaCodeDao.getShopCodeByAreaCode(contract.getManyShop());
                    mv.addObject("shopList2", shopList2);
                }

                mv.addObject("cardType", cardType);
            }

            mv.addObject("contract", contract);
            return mv;
        }
    }
}
